package com.b2c.product.controller.platform;

import com.b2c.product.pojo.dto.SpecGroupDto;
import com.b2c.product.service.SpecGroupService;
import content.enumeration.DeletedStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.Result;

@RestController("platformSpecGroupController")
@RequestMapping("platform/spg")
public class SpecGroupController {
    @Autowired
    SpecGroupService specGroupService;

    /**
     * 根据id获取品类
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getById(Integer id) {
        return specGroupService.queryById(id);
    }

    /**
     * 获取所有的品类
     *
     * @return
     */
    @GetMapping("/queryAll")
    public Result getAll() {
        return specGroupService.getAll();
    }

    /**
     * 修改品类状态
     */
    @PutMapping("/update/{status}")
    public Result updateStatus(@PathVariable DeletedStatus status, Integer specGroupId) {
        return specGroupService.updateStatus(status, specGroupId);
    }

    /**
     * 添加品类
     * @param specGroupDto
     * @return
     */
    @PostMapping
    public Result insert(@RequestBody SpecGroupDto specGroupDto){
        return specGroupService.insert(specGroupDto);
    }


}
